﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Kmust.App_Data.KmustDataTableAdapters;
using Kmust.Models.DeviceModels;
using Kmust.App_Data;

namespace Kmust.KmustControl
{
    /// <summary>
    /// DeviceControl.xaml 的交互逻辑
    /// </summary>
    public partial class DeviceControl : UserControl
    {
        Kmust.App_Data.KmustData.ExperimentDeviceDataTable devd = new KmustData.ExperimentDeviceDataTable();

        public DeviceControl()
        {
            InitializeComponent();
            iniDate();
        }

        private string setsource;

        public string setSource
        {
            get { return setsource; }
            set { 
                setsource = value;
                upDate(value);
            }
        }
        public static readonly DependencyProperty setSourceProperty = DependencyProperty.Register("setSource", typeof(string), typeof(DeviceControl));

        public void iniDate()
        {
            using (ExperimentDeviceTableAdapter dev = new ExperimentDeviceTableAdapter())
            {
                devd = dev.GetData();
            }

        }
        private void upDate(string value)
        {
            Device_Grid.ItemsSource = devd.Where(row => row.RoomCode.Equals(value));
            Device_Grid.UpdateLayout();
        }

        private void Device_Grid_Loaded(object sender, RoutedEventArgs e)
        {
           /// DeviceTableAdapter dev = new DeviceTableAdapter();           
          //  Device_Grid.ItemsSource = dev.GetData();
        }
    }
}
